Conversation
|
Hi, I think you're not handling correctly the flag for non-string value I recommend you to add test for You certainly need to do the check you did but after a toString call. |
…_EMPTY_STRING_NULL.
|
Thanks for your feedback! I added some cases and tried to be as precise as I could on type expectations. I feel like it's starting to get too complex when going deeper on union types. I'm not feeling fluent enough with PHPStan's API but I did my best. Again, tell me if I got something wrong here 😉 |
|
I feel like it could be simpler to look for something like with Some existing tests will fail, but I think it's an improvement. to fix. This is something related to (I think) |
|
I think you could try something like https://github.com/phpstan/phpstan-src/compare/2.1.x...VincentLanglet:phpstan-src:fix/filter_var?expand=1 with all your existing tests @niconoe- |
|
Thank you very much for your feedback! I'm giving it a try right now. I'm just curious about this snippet: In the EDIT: nvm, I got it. Aim is to remove any kind of StringType more specific than just a StringType, like an AccessoryNonEmptyStringType for instance, and replace it by a general StringType. This is due to possible sanitations when using flags that will remove unwanted chars from a non-empty-string that could lead to empty strings, and as we don't know, we infer the general StringType. |
|
I tried your proposal and I got 141 errors because of I think this is due to Forcing the input type as a String only matters when having the flag |
It's certainly because of the Maybe you'll have less failure to fix with https://github.com/phpstan/phpstan-src/compare/2.1.x...VincentLanglet:phpstan-src:fix/filter_var_2?expand=1 |
I figured this out too, but I kept the new method I had to fix the remaining failling unit test about |
|
I really don't understand why the unit tests are not passing on PHP 7.4 only and why the actual results differ from the expectations. The behavior of filter_var remained unchanged AFAIK. For the other errors on the pipeline, there are issues about things I did not impact, and memory limit troubles. For both of them, I don't know if I have something to do. |
tests/PHPStan/Analyser/nsrt/filter-var-returns-non-empty-string.php
Outdated
Show resolved
Hide resolved
tests/PHPStan/Analyser/nsrt/filter-var-returns-non-empty-string.php
Outdated
Show resolved
Hide resolved
|
About Mutation testing, I don't get how could I kill both kind of mutations like this: and when Therefore, I don't think such mutation is relevant IMO. And about other failing tests, this is about memory_limit so, I'm not sure I could do something to be fair. |
|
For Maybe some of the other condition can be checked the same way. |
|
I added unit tests with all combinations of types I got on this unit test file and I added I'm gonna need some time to fix this. |
|
@VincentLanglet I added unit tests with all types and anyOf all types + mixed, which helped into getting even more precise retun types, but some mutants are still alive. I'm not sure how I could kill them by tests. Do you have any ideas about it? Thanks a lot! |
I'm not fully familiar with all those mutation testing errors, I think this is something introduced by @staabm. |
|
Is there a way to run the mutation testing locally so I could give it a try to find how to kill the mutants? I really wish this PR not to be ignored because of this 😅 Any advice you could give @staabm ? Thanks a lot! |
Fixes phpstan/phpstan#13963